﻿using System;
using System.Collections;
using Wintellect.PowerCollections;

class PriorityQueue<T>:IEnumerable where T:IComparable<T>
{
    private OrderedBag<T> queue;

    public PriorityQueue()
    {
        queue = new OrderedBag<T>();
    }

    public void Enqueue(T itemToAdd)
    {
        queue.Add(itemToAdd); 
    }

    public T Dequeue()
    {
        var result = queue.GetFirst();
        queue.RemoveFirst();
        return result;
    }

    public IEnumerator GetEnumerator()
    {
        return queue.GetEnumerator();
    }

    public T this[int index]
    {
        get { return queue[index]; }
    }
}

